﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="user_manage.aspx.cs" Inherits="TCDC_System.Content.TransectionData.user_manage" %>

<%@ Register TagPrefix="uc" Src="~/UserControl/UserManageAdd.ascx" TagName="UserManageAdd" %>
<%@ Register TagPrefix="uc" Src="~/UserControl/UserManageRoleAdd.ascx" TagName="UserManageRoleAdd" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var exportData = function (GridData, GridPanel) {
            GridData.setValue(Ext.encode(GridPanel.getRowsValues({ selectedOnly: false })));
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="mainResource" runat="server" CleanResourceUrl="false" />
    <ext:Hidden ID="GridData" runat="server" />
    <ext:Viewport ID="Viewport1" runat="server" Layout="border">
        <Items>
            <ext:GridPanel ID="GridPanelUser" runat="server" Region="Center" DDGroup="gridDDGroup"
                EnableDragDrop="false" StripeRows="true" Title="User Manage" Icon="Vcard" Frame="true">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:Button ID="btAdd" runat="server" Text="Add" Icon="Add" OnDirectClick="AddUserManage"  />
                            <ext:ToolbarSeparator />
                            <ext:Button ID="btDelete" runat="server" Text="Delete" Icon="Delete">
                                <DirectEvents>
                                    <Click OnEvent="DeleteUser">
                                        <EventMask ShowMask="true" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarSeparator />
                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                            <%--<ext:Button ID="btExcel" runat="server" AutoPostBack="true" OnClick="ExportExcelUser"
                                Text="To Excel" Icon="PageExcel">
                                <Listeners>
                                    <Click Handler="exportData(#{GridData},#{GridPanelUser});" />
                                </Listeners>
                            </ext:Button>--%>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Store>
                    <ext:Store runat="server" ID="StoreUser" OnRefreshData="StoreUser_Refresh">
                        <Reader>
                            <ext:JsonReader IDProperty="user_id">
                                <Fields>
                                    <ext:RecordField Name="user_id" />
                                    <ext:RecordField Name="user_type_id" />
                                    <ext:RecordField Name="username" />
                                    <ext:RecordField Name="password" />
                                    <ext:RecordField Name="fname_th" />
                                    <ext:RecordField Name="lname_th" />
                                    <ext:RecordField Name="fname_en" />
                                    <ext:RecordField Name="lname_en" />
                                    <ext:RecordField Name="user_type_name_th" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel>
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column Header="ID" DataIndex="user_id" Width="80" Align="Center" />
                        <ext:Column Header="User Type" DataIndex="user_type_name_th" Width="100" Align="Center">
                            <Editor>
                                <ext:ComboBox ID="comboUserType" runat="server" ValueField="user_type_id"
                                            DisplayField="user_type_name_th" >
                                    <Store>
                                        <ext:Store ID="StoreUserType" runat="server">
                                            <Reader>
                                                <ext:JsonReader IDProperty="product_id">
                                                    <Fields>
                                                        <ext:RecordField Name="user_type_id" />
                                                        <ext:RecordField Name="user_type_name_th" />
                                                    </Fields>
                                                </ext:JsonReader>
                                            </Reader>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Username" DataIndex="username" Width="150">
                            <Editor>
                                <ext:TextField ID="TextField2" runat="server" AllowBlank="false" MsgTarget="Side" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="First Name (TH)" DataIndex="fname_th" Width="150">
                            <Editor>
                                <ext:TextField ID="TextField4" runat="server" AllowBlank="false" MsgTarget="Side" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Last Name (TH)" DataIndex="lname_th" Width="150">
                            <Editor>
                                <ext:TextField ID="TextField5" runat="server" AllowBlank="false" MsgTarget="Side" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="First Name (EN)" DataIndex="fname_en" Width="150">
                            <Editor>
                                <ext:TextField ID="TextField6" runat="server" AllowBlank="false" MsgTarget="Side" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Last Name (EN)" DataIndex="lname_en" Width="150">
                            <Editor>
                                <ext:TextField ID="TextField7" runat="server" AllowBlank="false" MsgTarget="Side" />
                            </Editor>
                        </ext:Column>
                        
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:GridFilters ID="GridFilters1" runat="server" Local="true">
                        <Filters>
                            <ext:StringFilter DataIndex="user_id" />
                            <ext:StringFilter DataIndex="user_type_id" />
                            <ext:StringFilter DataIndex="username" />
                            <ext:StringFilter DataIndex="fname_th" />
                            <ext:StringFilter DataIndex="lname_th" />
                            <ext:StringFilter DataIndex="fname_en" />
                            <ext:StringFilter DataIndex="lname_en" />
                        </Filters>
                    </ext:GridFilters>
                    <ext:RowEditor ID="RowEditorUser" runat="server" SaveText="Update">
                        <DirectEvents>
                            <AfterEdit OnEvent="UpdateUser">
                                <ExtraParams>
                                    <ext:Parameter Name="UserValue" Value="Ext.encode(#{GridPanelUser}.getRowsValues({selectedOnly:true}))"
                                        Mode="Raw">
                                    </ext:Parameter>
                                </ExtraParams>
                                <EventMask ShowMask="true" />
                            </AfterEdit>
                        </DirectEvents>
                    </ext:RowEditor>
                </Plugins>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                        <DirectEvents>
                            <RowSelect OnEvent="SelectUserRoleDetail" Buffer="100">
                                <ExtraParams>
                                    <ext:Parameter Name="user_id" Value="this.getSelected().data.user_id"
                                        Mode="Raw" />
                                </ExtraParams>
                            </RowSelect>
                        </DirectEvents>
                    </ext:RowSelectionModel>
                </SelectionModel>
                <LoadMask ShowMask="true" />
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="19" DisplayInfo="true"
                        EmptyMsg="No Request to display" />
                </BottomBar>
            </ext:GridPanel>

            <ext:GridPanel ID="GridPanelUserRoleDetail" runat="server" Region="South" Title="UserRoleDetail"
                DDGroup="gridDDGroup" EnableDragDrop="false" StripeRows="true" Collapsible="true"
                Collapsed="true" Layout="FitLayout" Icon="Vcard" Height="250">
                <TopBar>
                    <ext:Toolbar ID="Toolbar2" runat="server">
                        <Items>
                            <ext:Button ID="btAddUserRole" runat="server" Text="Add" Icon="Add" OnDirectClick="AddUserManageRole" />
                            <%--<ext:ToolbarSeparator />
                            <ext:Button ID="btDelete" runat="server" Text="Delete" Icon="Delete">
                                <DirectEvents>
                                    <Click OnEvent="DeleteUserRoleDetail">
                                        <EventMask ShowMask="true" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarSeparator />
                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                            <ext:Button ID="btExcel" runat="server" AutoPostBack="true" OnClick="ExportExcelUserRoleDetail"
                                Text="To Excel" Icon="PageExcel">
                                <Listeners>
                                    <Click Handler="exportData(#{GridData},#{GridPanelUserRoleDetail});" />
                                </Listeners>
                            </ext:Button>--%>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Store>
                    <ext:Store runat="server" ID="StoreUserRoleDetail" OnRefreshData="StoreUserRoleDetail_Refresh">
                        <Reader>
                            <ext:JsonReader IDProperty="user_role_id">
                                <Fields>
                                    <ext:RecordField Name="user_role_id" />
                                    <ext:RecordField Name="user_id" />
                                    <ext:RecordField Name="role_id" />
                                    <ext:RecordField Name="role_name" />
                                    <ext:RecordField Name="create_date" Type="Date" />
                                    <ext:RecordField Name="create_by" />
                                    <ext:RecordField Name="update_date" Type="Date" />
                                    <ext:RecordField Name="update_by" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel>
                    <Columns>
                        <ext:RowNumbererColumn />                                       
                        <ext:Column Header="Role Name" DataIndex="role_name" Width="100" Align="Center"/>
                        
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:GridFilters ID="GridFilters2" runat="server" Local="true">
                        <Filters>
                            <ext:StringFilter DataIndex="user_role_id" />
                            <ext:StringFilter DataIndex="user_id" />
                            <ext:StringFilter DataIndex="role_id" />
                            <ext:StringFilter DataIndex="create_date" />
                            <ext:StringFilter DataIndex="create_by" />
                            <ext:StringFilter DataIndex="update_date" />
                            <ext:StringFilter DataIndex="update_by" />
                        </Filters>
                    </ext:GridFilters>
                </Plugins>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true" />
                </SelectionModel>
                
                <LoadMask ShowMask="true" />
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar2" runat="server" PageSize="19" DisplayInfo="true"
                        EmptyMsg="No Request to display" />
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    <uc:UserManageAdd ID="UserManageAdd1" runat="server" />
    <uc:UserManageRoleAdd ID="UserManageRoleAdd1" runat="server" />
    </form>
</body>
</html>
